From: Marco Trevisan (TreviƱo) Date: Wed, 31 Jul 2019 12:10:31 +0000 (+0200) Subject: lightbox: Use common ease parameters and avoid similar codepaths X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~811^2^2~173 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c101196f5b1e550fc1ba2ea80e345f4a0e53296a;p=gnome-shell.git lightbox: Use common ease parameters and avoid similar codepaths Easing calls on show/hide functions have some parameters in common whether the radial effect is enabled or not. So instead of doing repeated calls with similar parameters, initialize common values in params objects. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/700 --- diff --git a/js/ui/lightbox.js b/js/ui/lightbox.js index fbbc01168..563bd637a 100644 --- a/js/ui/lightbox.js +++ b/js/ui/lightbox.js @@ -172,10 +172,13 @@ var Lightbox = class Lightbox { } show(fadeInTime) { - fadeInTime = fadeInTime || 0; - this.actor.remove_all_transitions(); + let easeProps = { + duration: fadeInTime || 0, + mode: Clutter.AnimationMode.EASE_OUT_QUAD + }; + let onComplete = () => { this.shown = true; this.emit('shown'); @@ -183,55 +186,38 @@ var Lightbox = class Lightbox { if (this._radialEffect) { this.actor.ease_property( - '@effects.radial.brightness', VIGNETTE_BRIGHTNESS, { - duration: fadeInTime, - mode: Clutter.AnimationMode.EASE_OUT_QUAD - }); + '@effects.radial.brightness', VIGNETTE_BRIGHTNESS, easeProps); this.actor.ease_property( - '@effects.radial.sharpness', VIGNETTE_SHARPNESS, { - duration: fadeInTime, - mode: Clutter.AnimationMode.EASE_OUT_QUAD, - onComplete - }); + '@effects.radial.sharpness', VIGNETTE_SHARPNESS, + Object.assign({ onComplete }, easeProps)); } else { - this.actor.ease({ + this.actor.ease(Object.assign(easeProps, { opacity: 255 * this._fadeFactor, - duration: fadeInTime, - mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete - }); + })); } this.actor.show(); } hide(fadeOutTime) { - fadeOutTime = fadeOutTime || 0; - this.shown = false; this.actor.remove_all_transitions(); + let easeProps = { + duration: fadeOutTime || 0, + mode: Clutter.AnimationMode.EASE_OUT_QUAD + }; + let onComplete = () => this.actor.hide(); if (this._radialEffect) { this.actor.ease_property( - '@effects.radial.brightness', 1.0, { - duration: fadeOutTime, - mode: Clutter.AnimationMode.EASE_OUT_QUAD - }); + '@effects.radial.brightness', 1.0, easeProps); this.actor.ease_property( - '@effects.radial.sharpness', 0.0, { - duration: fadeOutTime, - mode: Clutter.AnimationMode.EASE_OUT_QUAD, - onComplete - }); + '@effects.radial.sharpness', 0.0, Object.assign({ onComplete }, easeProps)); } else { - this.actor.ease({ - opacity: 0, - duration: fadeOutTime, - mode: Clutter.AnimationMode.EASE_OUT_QUAD, - onComplete - }); + this.actor.ease(Object.assign(easeProps, { opacity: 0, onComplete })); } }